﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfRouteManagement.aspx.cs" Inherits="msBsc.WebUi.wfRouteManagement" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>资讯信息管理</title>
    <link href="/jqPlugin/jqTab/ui.tabs.css" rel="stylesheet" type="text/css" />

    <script src="/jqPlugin/jqTab/ui.tabs.js" type="text/javascript"></script>

    <link href="/jqPlugin/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet" />
    <link href="/jqPlugin/SelectSimu/css/base.css" rel="stylesheet" />
    <script src='/??jqPlugin/kindeditor/kindeditor.js,jqPlugin/kindeditor/lang/zh_CN.js'
        type='text/javascript'></script>
    <style type="text/css">
        html, body {
            overflow: hidden;
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
        }

        .select .selectInput {
            width: 80px !important;
        }

        #outerInner, #province, #city {
            display: block;
            width: 80px !important;
            float: left;
            margin-right: 10px;
            z-index: 9999 !important;
        }
    </style>
    <script src="/jqPlugin/js/jBase.js"></script>
    <script src="/jqPlugin/js/jBPage.js"></script>
    <script src="/jqPlugin/js/laytpl.js"></script>
    <script src="/jqPlugin/SelectSimu/js/SelectSimu.js"></script>
    <!--end JS引用-->


</head>
<body>
    <form id="wfConstantHandle" method="post" runat="server">
        <asp:HiddenField ID="txtStatus" runat="server" Value="0" />
        <div style="width: 100%; text-align: left; margin: 0px 0px 0px 0px;">
            <div id="container2" style="width: 100%; margin-top: 3px; display: none;">
                <div id="fragment1">
                    <div id="divCondition" style="margin: 0px; border-style: solid; border-width: 1px; border-color: #C8D2E0;">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td class="label" width="70px">搜索名称
                                </td>
                                <td align="right" width="110px">
                                    <asp:TextBox ID="txtSearchCT" runat="server" Width="110px" MaxLength="100"></asp:TextBox>
                                </td>
                                <td class="label" width="70px">地区选择
                                </td>
                                <td width="280px">
                                    <div class="search">
                                        <span id="outerInner" class="select"></span>
                                        <span id="province" class="select"></span>
                                        <span id="city" class="select"></span>
                                    </div>
                                </td>
                                <td align="center">
                                    <input type="button" onclick="javascript: btnDo('mFinder'); return false;" value="查询(F)"
                                        id="btnFinder" accesskey="F" />
                                    <input type="button" onclick="javascript: viewItem('','add'); return false;" value="添加(A)"
                                        id="Button1" accesskey="E" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="bigbox2" style="margin: 0px; margin-top: 2px;">
                        <div id="gridbox1" style="border: 0px solid #cccccc; background-color: #f3f3f3; padding: 5px;">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>



    <script type="text/ecmascript">
        K = KindEditor;
        //        K.DEBUG = true;
        K.basePath = K.options.basePath = '/jqPlugin/kindeditor/';
        K.options.themesPath = K.options.basePath + 'themes/';
        K.options.langPath = K.options.basePath + 'lang/';
        K.options.pluginsPath = K.options.basePath + 'plugins/';

        var jlueditor7 = function () {
            var editor = new Sigma.Editor();
            var input = Sigma.$e('input', { type: 'text', value: editor.defaultValue || '', className: 'gt-editor-text', style: { width: '78px', styleFloat: 'left' } });
            var button = Sigma.$e('input', { type: 'button', value: editor.defaultValue || '', className: 'gt-editor-date', styleFloat: 'left' });
            editor.dom.style.overflow = 'hidden';
            editor.dom.appendChild(input);
            editor.dom.appendChild(button);

            editor.setSize = function (w, h) {
                this.width = w || this.width;
                this.height = h || this.height;
                if (this.width / 1 && this.width > 0) {
                    this.dom.style.width = (this.width - 1) + 'px';
                }
                if (this.height / 1 && this.height > 0) {
                    this.dom.style.height = (this.height - 1) + 'px';
                }
                this.dom.firstChild.style.width = (this.width - 20) + 'px';
            };


            var fillDate = function (imgurl, editorfile) {
                $(input).val(imgurl);
                editor.onClose && editor.onClose();
                editorfile.hideDialog();
            };

            var showCalendar = function () {
                var editorfile = K.editor({
                    allowFileManager: true
                });
                editorfile.fileManagerJson = '/pgajax.axd?F_MANA=1&rType1=0&rType2=0&COOKATHID=' + (typeof (cookesc) == "undefined" ? "" : cookesc)
                                    + "&fType=" + "image";
                editorfile.loadPlugin('filemanager', function () {
                    editorfile.plugin.filemanagerDialog({
                        viewType: 'VIEW',
                        dirName: 'image',
                        clickFn: function (url, title) {
                            fillDate(url, editorfile);
                        }
                    });
                });

            };
            Sigma.U.addEvent(button, 'click', showCalendar);

            editor.valueDom = input;
            return editor;
        };


        function viewItem(sid, reqType) {
            if (reqType == "md") {
                OpenDialog("/ShpMana/wfUpdateRoute.aspx?routeId=" + sid, null, null, "修改路线信息");
            }
            else if (reqType=="add") {
                OpenDialog("/ShpMana/AddRoute.aspx", null, null, "添加路线信息");
            }
            else if (reqType=="sd") {
                OpenDialog("/wp_TravelRouteInfo.htm?routeId=" + sid, null, null, "查看路线详情");
            }

        };

        function turnToDetial(dataId) {
            alert(dataId);
        }

        var clopCheckBox = { "True": "是", "False": "否" };
        function clrdCheckBox(value, record, columnObj, grid, colNo, rowNo) {
            var options = clopCheckBox;
            var ret = options[value];
            if (ret == null) {
                ret = value;
            }
            return ret;
        };

        var clopValid_NO = { "1": "等待审核", "2": "审核通过", "3": "审核不通过" };
        function clrdValid_NO(value, record, columnObj, grid, colNo, rowNo) {
            var options = clopValid_NO;
            var ret = options[value];
            if (ret == null) {
                ret = value;
            }
            return ret;
        };

        //要自定义显示，比如链接等字段如下buynow,在renderer函数中返回要显示的HTML编码字符
        var colsOption = [
            {
                id: 'ROUTE_ID', header: "修改信息", width: 70, resizable: false, filterable: false, exportable: false, sortable: false, printable: false,
                renderer: function (value, record, columnObj, grid, colNo, rowNo) {
                    return "<a  href=\"javascript:void(0);return false;\" onclick=\"javascript:viewItem('" + record.ROUTE_ID + "','md');return false;\" target='_self'>修改信息</a>";
                }
            },
            {
                id: 'IMAGE_EXPLAIN', header: "封面图片", width: 100, editor: jlueditor7, renderer: function (value, record, columnObj, grid, colNo, rowNo) {
                    if (record.IMAGE_EXPLAIN != "") {
                        return "<img src=" + record.IMAGE_EXPLAIN + " style='width:100px;height:100px;' />";
                    } else {
                        return "";
                    }
                }
            },
            {
                id: 'ROUTE_TITEL', header: "路线标题", width: 70, resizable: false, filterable: false, exportable: false, sortable: false, printable: false,
                renderer: function (value, record, columnObj, grid, colNo, rowNo) {
                    return "<a  href=\"javascript:void(0);return false;\" onclick=\"javascript:viewItem('" + record.ROUTE_ID + "','sd');return false;\" target='_self'>" + record.ROUTE_TITEL + "</a>";
                }
            },
            { id: 'INTRODUCTION', header: "路线简介", width: 260 },
            { id: 'IS_DJKINFO', header: "是否有地接客", width: 100, editor: { type: "select", options: clopCheckBox, defaultText: '1' }, renderer: clrdCheckBox },
            //{ id: 'IS_DELETE', header: "是否推荐", width: 100, editor: { type: "select", options: clopCheckBox, defaultText: 'False' }, renderer: clrdCheckBox },
        { id: 'C_NAME', header: "国家", width: 130 },
        { id: 'P_NAME', header: "城市", width: 130 },
        { id: 'A_NAME', header: "目的地", width: 130 },
        { id: 'IS_DELETE', header: "是否删除", width: 100, editor: { type: "select", options: clopCheckBox, defaultText: 'False' }, renderer: clrdCheckBox }
        ];

        //以下为固定的代码
        var gridOption1 = getGtOp('myGrid1', colsOption, 'gridbox1', 'BANK_ID');
        var mygrid1 = new Sigma.Grid(gridOption1);
        //////////////////////////////////////////////////////////
        function btnDo(sEbtn) {
            debugger;
            GtGrid1Action = sEbtn;
            var opart = GetGtParam("myGrid1");
            if (sEbtn == "mFinder") {
                doFinderGt('myGrid1');
            }
            else if (sEbtn == "btnEdit") {
                opart.AddCell("sEditMode", "EDIT");
                ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
            }
            else if (sEbtn == "btnSave") {
                doSaveGt('myGrid1');
            }
            else if (sEbtn == "btnConfirm" || sEbtn == "btnCancel") {
                var sidtem1 = GetGtSelectId('myGrid1');
                if (sidtem1) {
                    opart.AddCell("CHECK_ID", sidtem1);
                    ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
                } else {
                    alert("请先选择记录！");
                }
            }
            else {
                ajaxComm(opart, null, null, 'divCondition'); //调用页面回调，并传入参数
            }
            GtGrid1Action = "";
        };

        $(window).load(function () {

            //初始化步进式搜索框
            $('#container2').fadeIn("fast"); //初始化TAB页选择控件
            $('#container2 ul').tabs();
            mygrid1.render();
            mygrid1.readOnly = true;
            autogtResize("bigbox2", mygrid1);
            SetBtnEnable('btnEdit', 'btnSave,btnNotSave,btnConfirm,btnCancel');
        });
        function doTabChange(sStatus) {
            if (sStatus != $('#txtStatus').val()) {
                $('#txtStatus').val(sStatus); btnDo('mFinder');
            }
        };


        setArea("outerInner", 200, 1, 1, ["DF6723BE-A25C-4F77-BB49-A1662D3E6F2A"], ["中国"]);
        setArea("province", 200, 2, 1, ["AEF39D8E-D298-4AF1-AEC5-2B00D237F5F5"], ["北京"]);
        setArea("city", 200, 3, 1, [""], ["全部"]);
        var parentsId = "00000000-0000-0000-0000-000000000000";
        var GtGrid1Action;

        function setArea(input, width, zIndex, listNum, listValue, listOption) {
            $("#" + input).SelectSimu({
                width: width,
                zIndex: zIndex,
                listNum: listNum,
                listValue: listValue,
                listOption: listOption,
                imgSrc: '/jqPlugin/SelectSimu/img/icon_down.png'
            })
        }

        var currentOuterInnerId = "";
        var currentProvinceId = "";

        //收索按钮
        function search() {
            var outerInner = $("#outerInner input").val();
            var province = $("#province input").val();
            var city = $("#city input").val();
            if (outerInner == undefined || outerInner == null) {
                outerInner = ""
            }
            if (province == undefined || province == null) {
                province = ""
            }
            if (city == undefined || city == null) {
                city = ""
            }
            window.location.href = "/wp_VehicleList.htm?countryId=" + outerInner + "&cityId=" + province + "&destionId=" + city;
        }

        function updateSelet(inputId, valueData) {
            var selectValue = $("#" + inputId + " .selectList ul");
            selectValue.html("");
            var data = eval(valueData);
            for (var i = 0; i < data.length; i++) {
                selectValue.append('<li data-value="' + data[i].ID + '">' + data[i].Name + '</li>');
            }
            if (data.length > 0) {
                $("#" + inputId + " input").val(data[0].ID);
                $("#" + inputId + " span").text(data[0].Name);
            }
        }


        function GetGtParam(jqGridID) {
            var _jsParam = new jsonRow();
            if (jqGridID == "myGrid1") {
                GetFormJson("divCondition", _jsParam);
                _jsParam.AddCell("PPAGE", "wfConstantHandle"); //这个地方是该页面的类名
                _jsParam.AddCell("gtGridID", "myGrid1");
                _jsParam.AddCell("sRadom", $("#sRadom").val());
                _jsParam.AddCell("txtSearchCT", $("#txtSearchCT").val());
                _jsParam.AddCell("ACTION", GtGrid1Action);
                _jsParam.AddCell("parentsId", parentsId);
                _jsParam.AddCell("isAll", jqGridID);
                _jsParam.AddCell("countryId", $("#outerInner>.selectInput>input").val());
                _jsParam.AddCell("cityId", $("#province>.selectInput>input").val());
                _jsParam.AddCell("destinationId", $("#city>.selectInput>input").val());
                //这里可增加传入后台的参数
            } return _jsParam;
        };
        (function () {

            //jQuery.loadHtml('/pgajax.axd?GETLOGIN=1').done(function (_rets) {
            //    if (_rets) { $("#divLoginInfo").html(_rets); }
            //});


            $('#outerInner .selectList li').live('click', function () {
                var outerInnerId = this.getAttribute('data-value');
                if (currentOuterInnerId == outerInnerId) {
                    return;
                }
                currentOuterInnerId = outerInnerId;
                parentsId = outerInnerId;
                btnDo("getArea2");
            });
            $('#province .selectList li').live('click', function () {
                var provinceId = this.getAttribute('data-value');
                if (provinceId == currentProvinceId) {
                    return;
                }
                currentProvinceId = provinceId;
                parentsId = provinceId;
                btnDo("getArea3");
            });
        })();
        btnDo("initplace");
    </script>
</body>
</html>
